package com.lry.web.listener;



import com.lry.web.config.RabbitMQConfig;
import com.lry.web.fiction.mapper.FictionUpdateMapper;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@Component
public class FictionUpdateListener {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @Autowired
    FictionUpdateMapper fictionUpdateMapper;


    //每天3点更新
    @Scheduled(cron = "0 0 3 * * ?")
    public void updateFiction(){
        int num = SurviceListener.uuidSet.size();
        for(int i =0; i<num;i++){
            rabbitTemplate.convertAndSend(RabbitMQConfig.UPDATEEXCHANGE_NAME,"fiction.update",""+i+","+num);
        }
        fictionUpdateMapper.updateTime30T();
        }


    }

